export const lazy = {
  mounted(el, binding) {
    const options = {
      threshold: 0.5, // 触发加载的阈值，默认为0
    };

    const lazyImage = new IntersectionObserver((entries, observer) => {
      entries.forEach((entry) => {
        if (entry.isIntersecting) {
          const img = entry.target;
          img.src = binding.value;
          observer.unobserve(img);
        }
      });
    }, options);

    lazyImage.observe(el);
  },
};

export default {
  lazy
}
